<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 17-4-25
 * Time: 下午2:42
 */

namespace Admin\Model;

use Think\Model;
class RoleModel extends Model{


    public function catTree(){
        $data=$this->select();
        return $this->reSort($data);
    }
//递归函数
    public  function reSort($data,$pid=0,$level=0){
        static $ret=array();
        foreach($data as $k=>$v){
            if($v['parentid'] == $pid){
                $v['level'] = $level;
                $ret[]=$v;
                $this->reSort($data,$v['id'],$level+1);
            }
        }
        return $ret;
    }




} 